package com.ruoyi.training.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.training.service.ICertificateFieldService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.training.domain.CertificateField;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 证书自定义内容配置Controller
 * 
 * @author hcc
 * @date 2025-11-06
 */
@RestController
@RequestMapping("/certificateField")
public class CertificateFieldController extends BaseController
{
    @Autowired
    private ICertificateFieldService certificateFieldService;

    /**
     * 查询证书自定义内容配置列表
     */
    @RequiresPermissions("training:certificateField:list")
    @GetMapping("/list")
    public TableDataInfo list(CertificateField certificateField)
    {
        startPage();
        List<CertificateField> list = certificateFieldService.selectCertificateFieldList(certificateField);
        return getDataTable(list);
    }

    /**
     * 导出证书自定义内容配置列表
     */
    @RequiresPermissions("training:certificateField:export")
    @Log(title = "证书自定义内容配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CertificateField certificateField)
    {
        List<CertificateField> list = certificateFieldService.selectCertificateFieldList(certificateField);
        ExcelUtil<CertificateField> util = new ExcelUtil<CertificateField>(CertificateField.class);
        util.exportExcel(response, list, "证书自定义内容配置数据");
    }

    /**
     * 获取证书自定义内容配置详细信息
     */
    @RequiresPermissions("training:certificateField:query")
    @GetMapping(value = "/{certificateFieldId}")
    public AjaxResult getInfo(@PathVariable("certificateFieldId") String certificateFieldId)
    {
        return success(certificateFieldService.selectCertificateFieldByCertificateFieldId(certificateFieldId));
    }

    /**
     * 新增证书自定义内容配置
     */
    @RequiresPermissions("training:certificateField:add")
    @Log(title = "证书自定义内容配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CertificateField certificateField)
    {
        return toAjax(certificateFieldService.insertCertificateField(certificateField));
    }

    /**
     * 修改证书自定义内容配置
     */
    @RequiresPermissions("training:certificateField:edit")
    @Log(title = "证书自定义内容配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CertificateField certificateField)
    {
        return toAjax(certificateFieldService.updateCertificateField(certificateField));
    }

    /**
     * 删除证书自定义内容配置
     */
    @RequiresPermissions("training:certificateField:remove")
    @Log(title = "证书自定义内容配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{certificateFieldIds}")
    public AjaxResult remove(@PathVariable String[] certificateFieldIds)
    {
        return toAjax(certificateFieldService.deleteCertificateFieldByCertificateFieldIds(certificateFieldIds));
    }
}
